﻿using Natural.Actions;
using Natural.Attributes;
using Natural.Managers;
using Natural.Providers;
using Natural.Model;

namespace Natural.Decorators
{
    [Impl(Type = ImplType.Decorator, Name = "Update", Strategy = "Log", ApplyTo = typeof(object), Version = 0, Priority = 0)]
    public class UpdateLogDecorator<T> : Update<T> where T : class
    {
        private Update<T> Decorated;
        public UpdateLogDecorator(Update<T> decorated)
        {
            Decorated = decorated;
        }
        public override void Execute(ActionContext context, T entity, string includes)
        {
            Decorated.Execute(context,entity, includes);
            Logger.Log("Update", Serializer.Serialize(entity));
        }
    }
}
